<#assign className = table.className>   
<#assign classNameLower = className?uncap_first> 
package ${basepackage}.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import ${basepackage}.model.${className};
import ${basepackage}.service.${className}Service;


<#include "/java_imports.include">
@RestController
@RequestMapping("/${classNameLower}")
public class ${className}RestCtl extends  BaseCtl {

    protected final Logger logger = LoggerFactory.getLogger(${className}Ctl.class);

    @Autowired
    private ${className}Service  ${classNameLower}Service;

    /**
     * All rights Reserved, Designed By Kiven_Lu
     * @Description: (Action for Add 新增保存操作)
     * @author: Kiven_Lu
     * @version V1.0
     *
     */
    @PostMapping(value = "/save")
    @BussinessLog(description = "${className}信息新增")
    public RestResult save(${className} ${classNameLower}){
            ${classNameLower}Service.insert(${classNameLower});
        return RestResult.getSuccessInstance();
       
    }


    /**
     * All rights Reserved, Designed By Kiven_Lu
     * @Description: (Action for update 修改保存操作)
     * @author: Kiven_Lu
     * @version V1.0
     *
     */
    @PostMapping(value = "/update")
    @BussinessLog(description = "${className}信息修改")
    public RestResult update(${className} ${classNameLower}){
         ${classNameLower}Service.update(${classNameLower});
        return RestResult.getSuccessInstance();
    }
    

    /**
     * All rights Reserved, Designed By Kiven_Lu
     * @Description: (Action for SelectOneByKey 主键查询)
     * @author: Kiven_Lu
     * @version V1.0
     *
     */
    @GetMapping(value = "/query/{key}")
    public RestResult queryByPrimaryKey(@PathVariable String key){
       try{
            return RestResult.getSuccessInstance().setData( ${classNameLower}Service.queryByPrimaryKey(key));
       }catch(Exception e){
    	   	logger.error("Query Model ${className} By PrimaryKey Is Fail:"+e.getMessage());
       }
            return RestResult.getFailInstance();
    }
    

    /**
     * All rights Reserved, Designed By Kiven_Lu
     * @Description: (Action for SelectList 列表查询)
     * @author: Kiven_Lu
     * @version V1.0
     *
     */
    @GetMapping(value = "/list")
    public RestResult queryList(${className} ${classNameLower}){
       try{
            return RestResult.getSuccessInstance().setData(${classNameLower}Service.queryByCondition(${classNameLower}));
       }catch(Exception e){
    	   logger.error("Query Model ${className} List Fail :"+e.getMessage());
       }
            return RestResult.getFailInstance();
    }


    /**
     * All rights Reserved, Designed By Kiven_Lu
     * @Description: (Action for SelectList , PageHelper For Pagination 分页列表查询)
     * @author: Kiven_Lu
     * @version V1.0
     *
     */
    @GetMapping(value = "/pagelist")
    public RestResult queryList(${className} ${classNameLower}, Integer pageNo,Integer pageSize){
        try{
             PageHelper.startPage(pageNo!=null?pageNo:SysConst_PAGENO, pageSize!=null?pageSize:SysConst_PAGESIZE);
             List<${className}> orgCrops = ${classNameLower}Service.queryByCondition(${classNameLower});
             PageInfo<${className}> info = new PageInfo<>(orgCrops);
             return RestResult.getSuccessInstance().setData(info);
        }catch(Exception e){
             logger.error("Query Model ${className} List Fail :"+e.getMessage());
        }
        return RestResult.getFailInstance();
    }


    /**
     * All rights Reserved, Designed By Kiven_Lu
     * @Description: (Action for DeleteModel 物理删除)
     * @author: Kiven_Lu
     * @version V1.0
     *
     */
    @PostMapping("/delete/{key}")
    @BussinessLog(description = "${className}信息删除")
    public RestResult delete(@PathVariable String key){
            ${classNameLower}Service.delete(key);
            return RestResult.getSuccessInstance();
    }

   
}
